/*
 * @Author: Ryan Huang
 * @Description:
 * @Date: 2019-04-03 23:38:53
 */
package main

import (
	"encoding/json"
	"fmt"
)

type Monster struct {
	Name     string  `json:"name"`
	Age      int     `json:"age"`
	Birthday string  `json:"birthday"`
	Sal      float64 `json:"sal"`
	Skill    string  `json:"skill"`
}

func testStruct() {
	m := Monster{
		Name:     "牛魔王",
		Age:      500,
		Birthday: "19900421",
		Sal:      333333.11,
		Skill:    "lion roal",
	}
	strMonster, err := json.Marshal(m)
	if err != nil {
		fmt.Println("序列化失败")
	}
	var jsonStr string = string(strMonster)
	fmt.Println(jsonStr)
	var v map[string]string
	err = json.Unmarshal(strMonster, &v)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(v["name"])
}

func main() {
	testStruct()
}
